package com.gs.process.demo.controller;

import com.gs.process.core.ApprovalApi;
import com.gs.process.core.ApprovalDetailsApi;
import com.gs.process.demo.model.Leaves;
import com.gs.process.demo.service.LeavesService;
import com.gs.process.model.Approval;
import com.gs.process.model.ApprovalDetails;
import com.gs.process.model.dto.Constant;
import com.shallowUniverse.model.Params;
import com.shallowUniverse.model.Result;
import org.apache.ibatis.annotations.Results;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: Shuai Guo
 * @description:
 * @date: 2021/10/12
 * @version: 1.0
 */
@RestController
@RequestMapping("/demo")
public class DemoController {

    @Resource
    private ApprovalDetailsApi approvalDetailsApi;
    @Resource
    private LeavesService leavesService;
    @Resource
    private ApprovalApi approvalApi;

    @GetMapping
    public void demo() {
        Leaves leaves = new Leaves();
        leaves.setContent("请假");
        leaves.setFlowId(2L);
        leavesService.save(leaves);
    }

    @GetMapping("/approval")
    public void approval() {
        ApprovalDetails approvalDetails = new ApprovalDetails();
        approvalDetails.setApprovalId(1447750633489842176L);
        approvalDetails.setInfo(Constant.AUDIT_ALLOW_SIGN);
        approvalDetails.setRemark("同意");
        approvalDetails.setProcessNodeId("13");
        approvalDetailsApi.save(approvalDetails);
    }

    @PostMapping("/role")
    public Result<List<Approval>> listResult(@RequestBody Params<Approval> params) {
        return approvalApi.findByRole(params);
    }
}
